<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<link href="css/layout.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
function add_chk(o)
{
	if(!o.username.value)
	{
		alert("姓名不能为空")
		return false;
	}
	if(!o.email.value)
	{
		alert("邮箱不能为空")
		return false;
	}
	
	imgver_start(o);
	return false;
}
</script>
</head>

<body>

<div style="width:300px; margin:0 auto; padding-top:150px;">
  <form method="post" action="form.php" onsubmit="return add_chk(this)">
    <div class="book_input">
      <div>姓名 <span style="color:red;">*</span></div>
      <p><input type="text" name="username" value="1" /></p>
    </div>
    
    <div class="book_input">
      <div>邮箱 <span style="color:red;">*</span></div>
      <p><input type="text" name="email" value="2" /></p>
    </div>
    
    <div class="book_input">
      <div>电话</div>
      <p><input type="text" name="tel" /></p>
    </div>
    
    <div class="book_input book_textarea">
      <div>留言</div>
      <p><textarea style="height:80px;" name="content"></textarea></p>
    </div>
    <br />
    <button style="width:100%; height:30px; background:#000; color:#fff; border:0;" type="submit">提交</button>
  </form>
</div>

<!-- 核心代码 -->
<link href="css/imgver.css" type="text/css" rel="stylesheet" />
<script src="js/imgver.2.0.js" type="text/javascript"></script>
<div id="imgver"></div>
<script>
function imgver_start(o)
{	
	$.ajax({
		type:"post",
		url:"ajax.php",
		dataType:"json",
		
		success:function(data)
		{
			imgVer({
				el:'$("#imgver")',
				width:260,
				height:116,
				img:[
					'images/imgver/ver-1.png',
					'images/imgver/ver-2.png',
					'images/imgver/ver-3.png',
					'images/imgver/ver-4.png',
					'images/imgver/ver-5.png',
					'images/imgver/ver-6.png',
				],
				lan:'cn', //'cn' or 'en'
				randtox:data.randtox,
				form:o,
				success:function () {
					setTimeout(function(){
						o.submit();
					},500);
				},
				error:function () {
					//alert('错误什么都不执行');
					return false;
				}
			});
		}
	});
}


$(document).on("click",".imgver_bg",function(){
	$("#imgver").html("");
});
</script>
<!-- 核心代码 -->

</body>
</html>